cmake_minimum_required(VERSION 3.3 FATAL_ERROR)

project(Slider)

#set(VTK_DIR "/Users/dai/Qt/5.15.2/clang_64/lib/cmake/Qt5/lib/cmake/vtk-9.0")
set(VTK_DIR "/Users/dai/Work/vtk/VTK/VTK_MAKE_910/build/lib/cmake/vtk-9.0")


find_package(VTK COMPONENTS
        vtkCommonColor
        vtkCommonCore
        vtkCommonDataModel
        vtkFiltersSources
        vtkInteractionStyle
        vtkInteractionWidgets
        vtkRenderingContextOpenGL2
        vtkRenderingCore
        vtkRenderingFreeType
        vtkRenderingGL2PSOpenGL2
        vtkRenderingOpenGL2
        QUIET
        )

if (NOT VTK_FOUND)
    message("Skipping Slider: ${VTK_NOT_FOUND_MESSAGE}")
    return()
endif()
message (STATUS "VTK_VERSION: ${VTK_VERSION}")
if (VTK_VERSION VERSION_LESS "8.90.0")
    # old system
    include(${VTK_USE_FILE})
    add_executable(Slider MACOSX_BUNDLE Slider.cxx )
    target_link_libraries(Slider PRIVATE ${VTK_LIBRARIES})
else()
    # include all components
    # Prevent a "command line is too long" failure in Windows.
    set(CMAKE_NINJA_FORCE_RESPONSE_FILE "ON" CACHE BOOL "Force Ninja to use response files.")
    add_executable(Slider MACOSX_BUNDLE Slider.cxx )
    target_link_libraries(Slider PRIVATE ${VTK_LIBRARIES})
    # vtk_module_autoinit is needed
    vtk_module_autoinit(
            TARGETS Slider
            MODULES ${VTK_LIBRARIES}
    )
endif()